﻿using System;
using System.Web.Mvc;
using Blazing.BusinessObjects.Tagging;
using System.Collections.Generic;
using Blazing.BusinessObjects.Queries;
using Blazing.BusinessObjects.Cms;
using Blazing.WebFacade;
using Blazing.WebFacade.Extensions;
using Blazing.MvcBlog.Classes;

namespace Blazing.MvcBlog.Controllers
{
    public class HomeController : BaseController
    {
        private const string STR_TITLE = "Title";
        private const string STR_CONTENT = "Content";

        public HomeController() : base() { }

        public ActionResult Index()
        {
            PostsViewData viewData = new PostsViewData();

            viewData[STR_TITLE] = "Home Page";
            viewData[STR_CONTENT] = "Welcome to ASP.NET MVC!";

            string blogContentType = "content-post";
            Site _site = Request.Url.GetSite();

            IList<TaxonomyTag> tags = TaxonomyTag.Search(QrySearchTaxonomyTagsBySlugs.Query(new List<string> { blogContentType }));
            List<Contentpage> list = new PageController().GetPages(_site, (IList<TaxonomyTag>)tags, true, 10) as List<Contentpage>;
            list.Reverse();

            viewData.Posts = list;

            return this.View(viewData);
        }
    }
}
